package Day17;

import java.util.Random;
import java.util.Scanner;

public class View {
    private Scanner sc = new Scanner(System.in);
    private Random r = new Random();
    public int xxx(){
        System.out.println("请输入您的身份: 1-管理员   2-用户 0-退出");
        String s = sc.nextLine();
        int a = -1;
        try{
            a = Integer.parseInt(s);
            if(a<0 || a>2){
                System.out.println("输入有误2，请重新输入");
                //return xxx();
            }
        }catch (NumberFormatException e){

        }
        return a;
    }
    public int courier(){
        System.out.println("请输入您需要的操作： 1-添加快递  2-删除快递  3-修改快递  4-查看所有快递 0-退出操作");
        String s = sc.nextLine();
        int b = -1;
        try{
            b = Integer.parseInt(s);
        }catch (NumberFormatException e){

        }
        if(b<0 || b>4){
            System.out.println("输入有误，请重新输入");
            return courier();
        }
        return b;
    }

    //快递录入
    public Express add(){
        System.out.println("请输入快递单号:");
        String c = null;
        try{
            c = sc.nextLine();
        }catch (NumberFormatException e){
            System.out.println("输入有误");
        }
        System.out.println("请输入快递公司:");
        String s1 = sc.nextLine();
        Express e = new Express();
        e.setCompany(s1);
        e.setNumber(c);
        return e;
    }

    //快递删除
    public String delete(){
        System.out.println("请输入您要删除的快递单号:");
        String s = sc.nextLine();
        return s;
    }

    //找快递单号
    public String findByNumber(){
        System.out.println("请输入您要修改的快递单号：");
        String number = sc.nextLine();
        return number;
    }

    //快递修改
    public Express revise(){
        System.out.println("请输入新的快递单号：");
        String g = sc.nextLine();
        System.out.println("请输入新的快递公司");
        String next = sc.nextLine();
        Express e = new Express();
        e.setNumber(g);
        e.setCompany(next);
        return e;
    }

    //查看所有快递
//    public void printAll(){
//        DoExpress d = new DoExpress();
//        d.printlnAll();
//    }

    public int user(){
        System.out.println("请输入您的取件码:");
        String l = sc.nextLine();
        int h = -1;
        try{
            h = Integer.parseInt(l);
        }catch (NumberFormatException e){
            System.out.println("输入有误");
        }
        if(h<10000 || h>99999){
            System.out.println("输入有误1，请重新输入");
            user();
        }
        return h;
    }
}
